package com.ruoyi.project.module.columnNameSearch.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.module.columnNameSearch.domain.ColumnNameSearch;
import com.ruoyi.project.module.columnNameSearch.service.IColumnNameSearchService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 字段参考 信息操作处理
 * 
 * @author ruoyi
 * @date 2020-12-12
 */
@Controller
@RequestMapping("/module/columnNameSearch")
public class ColumnNameSearchController extends BaseController
{
    private String prefix = "module/columnNameSearch";
	
	@Autowired
	private IColumnNameSearchService columnNameSearchService;
	
	@RequiresPermissions("module:columnNameSearch:view")
	@GetMapping()
	public String columnNameSearch()
	{
	    return prefix + "/columnNameSearch";
	}
	
	/**
	 * 查询字段参考列表
	 */
	@RequiresPermissions("module:columnNameSearch:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(ColumnNameSearch columnNameSearch)
	{
		startPage();
        List<ColumnNameSearch> list = columnNameSearchService.selectColumnNameSearchList(columnNameSearch);
		return getDataTable(list);
	}
	
	/**
	 * 新增字段参考
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存字段参考
	 */
	@RequiresPermissions("module:columnNameSearch:add")
	@Log(title = "字段参考", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(ColumnNameSearch columnNameSearch)
	{		
		return toAjax(columnNameSearchService.insertColumnNameSearch(columnNameSearch));
	}

	/**
	 * 修改字段参考
	 */
	@GetMapping("/edit/{columnNameSearchId}")
	public String edit(@PathVariable("columnNameSearchId") Long columnNameSearchId, ModelMap mmap)
	{
		ColumnNameSearch columnNameSearch = columnNameSearchService.selectColumnNameSearchById(columnNameSearchId);
		mmap.put("columnNameSearch", columnNameSearch);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存字段参考
	 */
	@RequiresPermissions("module:columnNameSearch:edit")
	@Log(title = "字段参考", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(ColumnNameSearch columnNameSearch)
	{		
		return toAjax(columnNameSearchService.updateColumnNameSearch(columnNameSearch));
	}
	
	/**
	 * 删除字段参考
	 */
	@RequiresPermissions("module:columnNameSearch:remove")
	@Log(title = "字段参考", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(columnNameSearchService.deleteColumnNameSearchByIds(ids));
	}
	
}
